package com.example.administrator.guidepro.acitvity;

import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.administrator.guidepro.R;
import com.example.administrator.guidepro.bean.WetherInfo;
import com.example.administrator.guidepro.listenr.WetherListener;
import com.example.administrator.guidepro.mode.WetherMode;

public class MainActivity extends AppCompatActivity implements OnClickListener,WetherListener{
    EditText editCityNumber;
    Button button_ch,button_51;
    TextView textCityName,textTemp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    void initview(){//初始化控件}
        editCityNumber=(EditText)findViewById(R.id.edit_cityNumbe);
        button_ch=(Button)findViewById(R.id.button_ch);
        button_51=(Button)findViewById(R.id.button_51);
        textCityName=(TextView)findViewById(R.id.edit_cityNumbe);
        textTemp=(TextView)findViewById(R.id.text_temp);
        button_ch.setOnClickListener(this);
        button_51.setOnClickListener(this);
}

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button_ch:
                System.out.print("==>>"+"button is clicked,onClick()");
                WetherMode mode=new WetherMode();
                mode.getWether(editCityNumber.getText().toString(),this);

                break;
            case R.id.button_51:
                ///////////
                break;

        }
    }

    @Override
    public void OnResponse(WetherInfo wetherInfo) {
        textCityName.setText(wetherInfo.getCity());
        textTemp.setText(wetherInfo.getTemp());
    }

    @Override
    public void OnFailure(String msg) {
        textCityName.setText(msg);

    }
}
